<?php
class FdHelper
{
	public static $using_template_name;
	
	public static function getUsingTempleteName()
	{
		if(!empty(self::$using_template_name))
		{
			return self::$using_template_name;
		}
		$t = ConfigParser::get('fd','default_template_name');
		self::$using_template_name = $t;
		return $t;
	}
	
	public static function getViewFilePath($filename)
	{
		return ConfigParser::get('fd','templates_path') . self::getUsingTempleteName(). '/' . $filename .'.tpl';
	}
	
	public static function getModuleFilePath($filename)
	{
		return ConfigParser::get('fd','module_path') . $filename .'.php';
	}
	
	public static function getFromApi($script_name)
	{
		$tmp = file_get_contents(ConfigParser::get('fd','api_uri') . $script_name);
		$result = json_decode($tmp,TRUE);
		if(isset($result['result'])&&($result['result']=='success'))
		{
			return $result['data'];
		}
	}
	
	public static function encodeProductUri($uri_data,$product_id)
	{
		//return '/' . $uri_data['written_language_tag'] . '/product/' . $uri_data['category_name'] . '/' . $product_id .'/';
		return '#';//todo open
	}
}
?>
